﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Weazel.NativeMath;

#endregion

namespace Weazel.NativeMath.Test
{
	[TestClass]
	public class TestConstructors
	{
		[TestMethod]
		public void TestSingleStringArgumentConstructor_BinaryString_1()
		{
			Integer a = new Integer("0b1111");
			Assert.AreEqual(4, a.Width);
			Assert.AreEqual(1, a.Content.Length);
			Assert.AreEqual((uint)0xF, a.Content[0]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_BinaryString_2()
		{
			Integer a = new Integer("0b1111111111111111111111111111111111111111");
			Assert.AreEqual(40, a.Width);
			Assert.AreEqual(2, a.Content.Length);
			Assert.AreEqual(0xFFFFFFFF, a.Content[0]);
			Assert.AreEqual((uint)0xFF, a.Content[1]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_HexString_1()
		{
			Integer a = new Integer("0xFF");
			Assert.AreEqual(8, a.Width);
			Assert.AreEqual(1, a.Content.Length);
			Assert.AreEqual((uint)0xFF, a.Content[0]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_HexString_2()
		{
			Integer a = new Integer("0xFFFFFFFFFF");
			Assert.AreEqual(40, a.Width);
			Assert.AreEqual(2, a.Content.Length);
			Assert.AreEqual((uint)0xFFFFFFFF, a.Content[0]);
			Assert.AreEqual((uint)0xFF, a.Content[1]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_UnsignedDecimalString_1()
		{
			Integer a = new Integer("123456");
			Assert.AreEqual(17, a.Width);
			Assert.AreEqual(1, a.Content.Length);
			Assert.AreEqual((uint)123456, a.Content[0]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_UnsignedDecimalString_2()
		{
			Integer a = new Integer("12345678910111213");
			Assert.AreEqual(54, a.Width);
			Assert.AreEqual(2, a.Content.Length);
			Assert.AreEqual((uint)0x5DF2BDED, a.Content[0]);
			Assert.AreEqual((uint)0x2BDC54, a.Content[1]);
		}

		[TestMethod]
		public void TestSingleStringArgumentConstructor_SignedDecimalString_1()
		{
			Integer a = new Integer("-123456");
			Assert.AreEqual(18, a.Width);
			Assert.AreEqual(1, a.Content.Length);
			Assert.AreEqual((uint)0xFFFE1DC0, a.Content[0]);
		}

		//[TestMethod]
		//public void TestSingleStringArgumentConstructor_InvalidArgument_1()
		//{
		//  try
		//  {
		//    Integer a = new Integer("0x0ABCDEFGHIJKLM"); // not a number!
		//  }
		//  catch (NotSupportedException)
		//  {
		//    return; // success
		//  }

		//  Assert.Fail();
		//}
	}
}
